$(function(){
	var recoedType = 2;
	var usertype = $('#usertype option:selected') .val();//选中的值
	var phone=$("#phone").val();//用户昵称
	//自动加载

	loadData(recoedType,0,usertype,phone,1);
});


function loadData(recoedType,withdrawStatus,usertype,phone,pageNo){
	var id="",pageSize = 8 ,idphone="",html="",index=0,realName="",money="",transactionNum="",payType="",gmtDatetime="" ,totalMoney=0.00;
		//获取用户信息列表

		$("#thislist").html("");
	  $.ajax({  
        type : "GET",  
        url : urlcore + "/api/cashRecord/cashRecordList?recoedtype="+recoedType+"&withdrawStatus="+withdrawStatus+"&usertype="+usertype+"&phone="+phone+"&pageNum="+pageNo+"&pageSize="+pageSize, 
        dataType : "json",
        headers:{"Content-Type":"application/json;charset=UTF-8"},
        success: function(data) {//data是返回的hash,key之类的值，key是定义的文件名 
        	var da=data.data.list;
        	var totalMoney2=0.00;
        	if(data.success==true){
        		for(var i=0;i<da.length;i++ ){
        			++index;
        			id=da[i].id;       		
        			//获取总金额      			
        			if(da[i].money!=null){
        				totalMoney+=parseFloat(da[i].money);
        			}
        			totalMoney2=totalMoney.toFixed(2);
        			realName=da[i].user.realName;
        			userType=da[i].user.userType==2?"骑手":da[i].user.userType==3?"商家":"用户";
        			Status=da[i].withdrawStatus;
        			if(Status==1){
        				Status="待处理";
        			}else if(Status==2){
        				Status="已提现";
        			}else if(Status==3){
        				Status="已驳回";
        			}
/*        			var type=da[i].recoedType;
					if(type==1){
						type= "充值";
					}
					if(type==2){
						type=  "提现";
					}
					if(type==3){
						type=  "消费";
					}
					if(type==4){
						type=  "收入"
					}
					if(type==5){
						type=  "其他"
					}
        			recoedType= type;*/
        			secondId=da[i].user.secondId;
        			idphone=da[i].user.phone;
        			money=da[i].money;
        			transactionNum=da[i].transactionNum;
        			payType=da[i].payType;
        			if(payType==1){
        				payType="余额支付";
        			}else if(payType==2){
        				payType="支付宝支付";
        			}else if(payType==3){
        				payType="微信支付";
        			}else if(payType==4){
        				payType="押金支付";
        			}else if(payType==null){
        				payType="/";
        			}
        			
        			gmtDatetime=da[i].gmtDatetime;
          html += '<tr class="footable-even" style="display: table-row;">'+
            	 '	<td class="footable-visible">'+index+'</td>'+
            	'	<td class="footable-visible">'+secondId+'</td>'+
				'	<td class="footable-visible">'+money+'</td>'+            				
				'	<td class="footable-visible">'+userType+'</td>'+
				'	<td class="footable-visible">'+new Date(gmtDatetime).pattern("yyyy-MM-dd hh:mm:ss")+'</td>'+
				'	<td class="footable-visible">'+Status+'</td>'+
				'	<td class="footable-visible">'+
						'	<a class="btn btn-primary btn-xs" href="drawmoney_details.html?id='+id+'"> 详细</a>';
				html +=
				'</td>'+
				'</tr>';
        		}
        		$("#thislist").append(html);
        		$("#totalMoney").html(totalMoney2);
        		$('#thiscount').text(data.data.total);
        		$("#pager").pager({
					pagenumber: pageNo, 
					pagecount:data.data.pages,
					totalcount:data.data.total,
					buttonClickCallback: PageClick
				}); 
            }
        },
        error:function(){  
            alert("失败");  
        }  
    }); 
	
}
//回调函数  
	PageClick = function(pageclickednumber) {  
		var recoedType = 2;//选中的值
		var usertype = $('#usertype option:selected') .val();//选中的值
		var phone=$("#phone").val();//用户昵称
	    loadData(recoedType,0,usertype,phone,pageclickednumber)
	}
	




//搜索
function searchuser() {
		var recoedType = 2;//选中的值
		var usertype = $('#usertype option:selected') .val();//选中的值
		var phone=$("#phone").val();//用户昵称
	    loadData(recoedType,0,usertype,phone,1)
}

